import { defineStore } from 'pinia';
import { useRoutePath } from '@/composables';

interface AppState {
  /** 用户信息 */
  activeTab: string;
  configVisible: Record<string, boolean>;
}

export const useAppStore = defineStore('app-store', {
  state: (): AppState => ({
    activeTab: useRoutePath(),
    configVisible: {}
  }),
  getters: {
    /** 是否登录 */
    getActiveTab: state => state.activeTab,
    getConfigVisible: state => state.configVisible
  },
  actions: {
    setActiveTab(tab: string) {
      this.activeTab = tab;
    },
    setConfigVisible(config: Record<string, boolean>) {
        this.configVisible = config;
    },
    /** 重置app状态 */
    resetAuthStore() {
      this.$reset();
    }
  }
});
